/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package csse3004.GD.PM;

import csse3004.GD.DA.PollMasterDA;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import org.springframework.web.servlet.mvc.SimpleFormController;

import org.springframework.web.servlet.view.RedirectView;

/**
 *
 * @author s4201567 Tony Yu
 */
public class EditPartListController extends SimpleFormController {

    private PollMasterService pms = new PollMasterDA();
    
    public ModelAndView onSubmit(Object command) throws ServletException {
        EditPartList epl = (EditPartList)command;
        int tempID = epl.getTemplateID();
        
        EditPartList addUser = (EditPartList) command;
        int pid = addUser.getPollUserID();

         try {
            if (pid >= 0) {
                logger.info(pid);
                logger.info(tempID);
                //pms add Part to DB function

                String addPart = "Particpant has been successfully added!";
                logger.info(addPart);

                return new ModelAndView("successMsg", "addPart", addPart);
            } else {
                String addFail = "Participant has not been added!";
                logger.info(addFail);

                return new ModelAndView("successMsg", "addFail", addFail);
            }
         } catch (Exception e) {
             logger.info(e);
             return new ModelAndView("editPartList");
         }
    }
}